{% load static %}
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>WMS移动日志分析系统</title>

    <!-- Bootstrap 5 CSS -->
    <link rel="stylesheet" href="{% static 'plugins/bootstrap-5.3.0-alpha1-dist/css/bootstrap.min.css' %}">
    <!-- Font Awesome -->
    <link rel="stylesheet" href="{% static 'plugins/fontawesome-free-6.7.2-web/css/all.min.css' %}">

    <style>
        :root {
            --primary-gradient: linear-gradient(135deg, #6366f1 0%, #4f46e5 100%);
            --secondary-gradient: linear-gradient(45deg, #8b5cf6, #ec4899);
            --success-color: #10b981;
            --error-color: #ef4444;
            --glass-bg: rgba(255, 255, 255, 0.9);
        }

        body {
            background: var(--primary-gradient);
            min-height: 100vh;
            font-family: 'Inter', 'Helvetica Neue', Arial, 'PingFang SC', sans-serif;
            backdrop-filter: blur(10px);
        }

        .main-card {
            border: none;
            border-radius: 2rem;
            box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
            overflow: hidden;
            background: var(--glass-bg);
            backdrop-filter: blur(16px);
        }

        .card-header {
            background: var(--secondary-gradient);
            padding: 3rem 2rem;
            position: relative;
            overflow: hidden;
        }

        .card-header::before {
            content: '';
            position: absolute;
            top: -50%;
            left: -50%;
            width: 200%;
            height: 200%;
            background: repeating-linear-gradient(
                45deg,
                rgba(255,255,255,0.1) 25%,
                transparent 25%,
                transparent 50%,
                rgba(255,255,255,0.1) 50%,
                rgba(255,255,255,0.1) 75%,
                transparent 75%,
                transparent
            );
            animation: animateBG 20s linear infinite;
        }

        @keyframes animateBG {
            0% { transform: rotate(0deg); }
            100% { transform: rotate(360deg); }
        }

        .file-input-group {
            border: 2px dashed #e5e7eb;
            border-radius: 1rem;
            transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
            background: rgba(255, 255, 255, 0.95);
        }

        .file-input-group.dragover {
            border-color: #6366f1;
            background: rgba(99, 102, 241, 0.05);
            transform: translateY(-2px);
        }

        .upload-icon {
            font-size: 2.5rem;
            color: #6366f1;
            transition: transform 0.3s ease;
        }

        .btn-primary {
            background: var(--secondary-gradient);
            border: none;
            padding: 1rem 2.5rem;
            font-size: 1.1rem;
            position: relative;
            overflow: hidden;
            transition: all 0.3s ease;
        }

        .btn-primary::after {
            content: '';
            position: absolute;
            top: -50%;
            left: -50%;
            width: 200%;
            height: 200%;
            background: rgba(255,255,255,0.1);
            transform: rotate(45deg);
            transition: all 0.5s ease;
        }

        .btn-primary:hover {
            transform: translateY(-2px);
            box-shadow: 0 10px 20px rgba(99, 102, 241, 0.3);
        }

        .btn-primary:hover::after {
            left: 120%;
        }

        .instructions {
            background: rgba(255, 255, 255, 0.95);
            border-radius: 1rem;
            padding: 1.5rem;
            margin-top: 2rem;
            box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
        }

        .feature-icon {
            width: 40px;
            height: 40px;
            border-radius: 12px;
            display: flex;
            align-items: center;
            justify-content: center;
            margin-right: 1rem;
        }

        @media (max-width: 768px) {
            .main-card {
                margin: 1rem;
                border-radius: 1.5rem;
            }

            .card-header {
                padding: 2rem 1rem;
            }
        }
    </style>
</head>
<body>
    <div class="container py-5">
        <div class="main-card">
            <!-- 动态卡片头部 -->
            <div class="card-header text-center position-relative">
                <div class="position-relative z-index-1">
                    <h1 class="text-white mb-3 display-4 fw-bold">
                        <i class="fas fa-robot me-3"></i>WMS 移动日志分析系统
                    </h1>
                    <p class="text-white-80 lead mb-0">新一代人工智能驱动数据处理平台</p>
                </div>
            </div>

            <!-- 卡片主体 -->
            <div class="card-body p-4 p-lg-5">
                <!-- 动态错误提示 -->
                {% if error %}
                <div class="alert alert-danger d-flex align-items-center mb-4 animate__animated animate__shakeX">
                    <i class="fas fa-exclamation-circle fs-4 me-3"></i>
                    <div class="flex-grow-1">{{ error }}</div>
                </div>
                {% endif %}

                <!-- 增强上传表单 -->
                <form method="post" enctype="multipart/form-data" id="uploadForm">
                    {% csrf_token %}

                    <!-- 拖拽上传区域 -->
                    <div class="mb-4">
                        <label class="form-label fs-5 fw-bold text-dark mb-3">选择或拖放文件</label>
                        <div class="file-input-group" id="dropZone">
                            <div class="py-5 text-center">
                                <div class="mb-4">
                                    <i class="fas fa-cloud-upload-alt upload-icon"></i>
                                </div>
                                <input
                                    type="file"
                                    class="form-control visually-hidden"
                                    name="file"
                                    id="fileInput"
                                    accept=".xlsx, .xls"
                                    required
                                    onchange="updateFileName()"
                                >
                                <label for="fileInput" class="btn btn-lg btn-light mb-2 px-4">
                                    <i class="fas fa-folder-open me-2"></i>浏览文件
                                </label>
                                <div id="fileName" class="text-muted small mt-2"></div>
                                <div class="text-muted mt-2">支持 .xlsx, .xls 格式</div>
                            </div>
                        </div>
                    </div>

                    <!-- 动态提交按钮 -->
                    <div class="d-grid gap-2 mt-4">
                        <button type="submit" class="btn btn-primary btn-lg py-3">
                            <i class="fas fa-bolt-lightning me-2"></i>立即智能分析
                        </button>
                    </div>
                </form>

                <!-- 增强操作说明 -->
                {% if not error %}
                <div class="instructions mt-5">
                    <h5 class="mb-4 fw-bold text-dark">
                        <i class="fas fa-graduation-cap me-2"></i>使用指南
                    </h5>
                    <div class="row g-4">
                        <div class="col-md-4">
                            <div class="d-flex align-items-center">
                                <div class="feature-icon bg-success">
                                    <i class="fas fa-check text-white"></i>
                                </div>
                                <div>
                                    <h6 class="mb-1">数据规范</h6>
                                    <p class="text-muted small mb-0">保持原始数据结构完整</p>
                                </div>
                            </div>
                        </div>
                        <div class="col-md-4">
                            <div class="d-flex align-items-center">
                                <div class="feature-icon bg-primary">
                                    <i class="fas fa-clock text-white"></i>
                                </div>
                                <div>
                                    <h6 class="mb-1">处理时效</h6>
                                    <p class="text-muted small mb-0">30秒～2分钟极速处理</p>
                                </div>
                            </div>
                        </div>
                        <div class="col-md-4">
                            <div class="d-flex align-items-center">
                                <div class="feature-icon bg-info">
                                    <i class="fas fa-download text-white"></i>
                                </div>
                                <div>
                                    <h6 class="mb-1">结果获取</h6>
                                    <p class="text-muted small mb-0">自动下载分析报告</p>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
                {% endif %}
            </div>
        </div>
    </div>

    <script>
        // 增强文件交互功能
        const dropZone = document.getElementById('dropZone');
        const fileInput = document.getElementById('fileInput');

        // 拖拽功能
        dropZone.addEventListener('dragover', (e) => {
            e.preventDefault();
            dropZone.classList.add('dragover');
        });

        dropZone.addEventListener('dragleave', () => {
            dropZone.classList.remove('dragover');
        });

        dropZone.addEventListener('drop', (e) => {
            e.preventDefault();
            dropZone.classList.remove('dragover');
            fileInput.files = e.dataTransfer.files;
            updateFileName();
        });

        // 文件选择更新
        function updateFileName() {
            const file = fileInput.files[0];
            const fileNameDiv = document.getElementById('fileName');

            if (file) {
                fileNameDiv.innerHTML = `
                    <span class="text-success">
                        <i class="fas fa-check-circle me-2"></i>${file.name}
                    </span>
                    <span class="text-muted small ms-2">(${(file.size/1024/1024).toFixed(2)} MB)</span>
                `;
            } else {
                fileNameDiv.textContent = '尚未选择任何文件';
            }
        }
    </script>

    <!-- Bootstrap 5 JS -->
    <script src="{% static 'plugins/bootstrap-5.3.0-alpha1-dist/js/bootstrap.bundle.min.js' %}"></script>
</body>
</html>